home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / lfsrebuild / layout.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  6.4 KB  |  182 lines

  1.  
  2. /*
  3.  * Data blocks are added to LfsSeg structures in units of LfsSegElement's.
  4.  */
  5. typedef struct LfsSegElement {
  6.     Address       address;         /* The address of the start of the buffer. */
  7.     unsigned int lengthInBlocks;  /* Length of the buffer in units of file 
  8.                    * system blocks. */
  9.     ClientData   clientData;      /* ClientData usable by the callback 
  10.                    * functions. */
  11. } LfsSegElement;
  12.  
  13. /*
  14.  * LfsSegLogRange describes the position in the segmented log of a segment. 
  15.  */
  16. typedef struct LfsSegLogRange {
  17.     int        current;    /* Current segment being accessed */
  18.     int        prevSeg;    /* The segment that was written before the
  19.                  * current segment. */
  20.     int        nextSeg;    /* Next segment to be written after the
  21.                  * current segment. */
  22. } LfsSegLogRange;
  23.  
  24. /*
  25.  * The LfsSeg structure is used to describe a segment while objects are being
  26.  * added to the segment during writing and removed from the segment during
  27.  * cleaning.  A segment is divided into two regions: the data block region
  28.  * and the summary region.  The data block region is may contain zero to 
  29.  * the segment size (segmentSize in LfsSuperBlockHdr)-1 blocks. The blocks are
  30.  * pointed to by an array of LfsSegElement.  The summary region is allocated
  31.  * in bytes and may grow from one block to an entire segment.
  32.  */
  33.  
  34. typedef struct LfsSeg {
  35.     LfsSegElement *segElementPtr; /* The SegElements making up the data 
  36.                    * region of the segment. */
  37.     char       *memPtr;    /* Segment memory allocated for segment. */
  38.     LfsSegLogRange logRange;    /* Placement of segment in segmented log. */
  39.     int        numElements;      /* Number of LfsSegElement describing the 
  40.                    * segment. */
  41.     int        numBlocks;        /* Number of blocks in segment. */
  42.     int        startBlockOffset; /* Starting block offset of this segment. */
  43.     int        activeBytes;      /* Number of active bytes in segment. */
  44.     /*
  45.      * Some operations of segments require scanning thru the summary 
  46.      * and SegElements.  The following fields keep the start require
  47.      * from this scans. 
  48.      */
  49.     LfsSegSummary    *curSegSummaryPtr; /* Summary of current summary 
  50.                         * block. */
  51.     LfsSegSummaryHdr    *curSummaryHdrPtr; 
  52.                 /* Current module header being processed. */
  53.     int         curElement;    /* Current LfsSegElement. */
  54.     int         curBlockOffset;    /* The block offset into the segment of the
  55.                  * end of curElement. */
  56.     int         curDataBlockLimit;   /* Last block offset available in the 
  57.                    * segment. */
  58.     char     *curSummaryPtr;    /* Current offset into the summary region. */
  59.     char     *curSummaryLimitPtr; /* Current last byte of the summary block 
  60.                    * plus 1. */
  61.  
  62. } LfsSeg;
  63.  
  64.  
  65.  
  66. /*
  67.  * Macros for uses in SegIoInterface callback procedures. 
  68.  *
  69.  * See documentation in the procedure header for the slow version.
  70.  */
  71. /*
  72.  * Increase the size of the summary region to bytesNeeded bytes.
  73.  * char *
  74.  * LfsSegGrowSummary(segPtr, blocks,  bytesNeeded)
  75.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  76.  *    int    blocks;        -- Insure this many data blocks remain.
  77.  *    int    bytesNeeded;    -- Number of bytes needed in the summary
  78.  *                   region.
  79.  */
  80. #define    LfsSegGrowSummary(segPtr, blocks, bytesNeeded) \
  81.     LfsSegSlowGrowSummary((segPtr), (blocks), (bytesNeeded), FALSE)
  82.  
  83. /*
  84.  * Return the value of the current pointer into the summary region.
  85.  * char *
  86.  * LfsSegGetSummaryPtr(segPtr)
  87.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  88.  */
  89. #define    LfsSegGetSummaryPtr(segPtr)  ((segPtr)->curSummaryPtr)
  90.  
  91. /*
  92.  * Set the value of the current end of summary region.
  93.  * char *
  94.  * LfsSegSegSummaryPtr(segPtr, newEndPtr)
  95.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  96.  *    char    *newEndPtr;    -- New value
  97.  */
  98. #define    LfsSegSetSummaryPtr(segPtr, newEndPtr)  \
  99.     ((segPtr)->curSummaryPtr = (newEndPtr))
  100.  
  101. /*
  102.  * Return the number of summary bytes left in the summary segment.
  103.  * int
  104.  * LfsSegSummaryBytesLeft(segPtr)
  105.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  106.  */
  107.  
  108. #define    LfsSegSummaryBytesLeft(segPtr) \
  109.     ((segPtr)->curSummaryLimitPtr - (segPtr)->curSummaryPtr)
  110.  
  111. /*
  112.  * Return the number of file system blocks left in the segment.
  113.  * int
  114.  * LfsSegBlocksLeft(segPtr)
  115.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  116.  */
  117. #define    LfsSegBlocksLeft(segPtr) ((segPtr)->curDataBlockLimit - \
  118.                   (segPtr)->curBlockOffset)
  119.  
  120. /*
  121.  * Return the disk address of an LfsSegElement
  122.  * int
  123.  * LfsSegDiskAddress(segPtr, segElementPtr)
  124.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  125.  *    LfsSegElement *segElementPtr; -- Segment element of interest
  126.  */
  127.  
  128. #define    LfsSegDiskAddress(segPtr, segElementPtr) \
  129.         LfsSegSlowDiskAddress((segPtr), (segElementPtr))
  130. /*
  131.  * Add a LfsSegElement to a segment.
  132.  * LfsSegElement
  133.  * LfsSegAddDataBuffer(segPtr, blocks, bufferPtr, clientData)
  134.  *    LfsSeg    *segPtr;     -- Segment of interest. 
  135.  *    int    blocks;        -- Size of buffer to add in fsBlocks.
  136.  *    char   *bufferPtr;    -- Buffer to add.
  137.  *    ClientData clientData;    -- ClientData associated with this field.
  138.  */
  139.  
  140. #define    LfsSegAddDataBuffer(segPtr, blocks, bufferPtr, clientData) \
  141.     LfsSegSlowAddDataBuffer((segPtr), (blocks), (bufferPtr), (clientData))
  142.  
  143. #define    LfsSegGetBufferPtr(segPtr) \
  144.             ((segPtr)->segElementPtr + (segPtr)->curElement)
  145. #define    LfsSegSetBufferPtr(segPtr, bufferPtr) \
  146.         ((segPtr)->curElement = ((bufferPtr) - (segPtr)->segElementPtr))
  147.  
  148. #define    LfsSegSetCurBlockOffset(segPtr, blockOffset) \
  149.             ((segPtr)->curBlockOffset = blockOffset)
  150.  
  151. #define    LfsSegFetchBytes(segPtr, blockOffset, size) \
  152.     ((segPtr)->memPtr + LfsSegSize((segPtr)->lfsPtr) - \
  153.         LfsBlocksToBytes((segPtr)->lfsPtr, blockOffset))
  154. /* procedures */
  155.  
  156. extern char *LfsSegSlowGrowSummary _ARGS_((LfsSeg *segPtr, 
  157.             int dataBlocksNeeded, int sumBytesNeeded, 
  158.             Boolean addNewBlock));
  159. extern LfsDiskAddr LfsSegSlowDiskAddress _ARGS_((LfsSeg *segPtr, 
  160.             LfsSegElement *segElementPtr));
  161. extern LfsSegElement *LfsSegSlowAddDataBuffer _ARGS_((LfsSeg *segPtr,
  162.             int blocks, char *bufferPtr, ClientData clientData));
  163.  
  164. extern Boolean WriteSegCheckpoint _ARGS_((int diskId, char *checkPointPtr,
  165.                      int    *checkPointSizePtr));
  166.  
  167.  
  168. extern Boolean LfsSegUsageCheckpoint _ARGS_((LfsSeg *segPtr, 
  169.         char *checkPointPtr, int *checkPointSizePtr));
  170. extern Boolean LfsDescMapCheckpoint _ARGS_((LfsSeg *segPtr, 
  171.         char *checkPointPtr, int  *checkPointSizePtr));
  172.  
  173. extern void LfsSegUsageCheckpointUpdate _ARGS_((char *checkPointPtr, int size));
  174.  
  175. extern ReturnStatus LfsGetLogTail _ARGS_((
  176.             LfsSegLogRange *logRangePtr, int *startBlockPtr ));
  177.  
  178. extern void LfsSetLogTail _ARGS_((
  179.             LfsSegLogRange *logRangePtr, int startBlock, 
  180.             int activeBytes));
  181.  
  182.